using System;
using System.Data;
using System.Web.UI.WebControls;
using NCS.Library;
using NCS.Library.Components.Modules;
using NCS.Library.Utilities;
using NCS.Module.LinkSite.Library.DataAccess;

namespace NCS.Module.LinkSite.Web
{
	public partial class WebLink : ModuleControlBase
	{
		protected void Page_Load(object sender, EventArgs e)
		{
            if (!Page.IsPostBack)
            {
                DataTable dtCatalog = LinkCatalogDB.GetAll();
                dropCatalogWebLink.DataSource = dtCatalog;
                dropCatalogWebLink.DataBind();
                dropCatalogWebLink.Items.Insert(0, new ListItem(MultiLanguage.Initialize.GetString("CataglogLink"), "#"));

                DataTable dtLinks = LinkDB.GetAll(AppEnv.GetLanguage());
                dropWebLink.DataSource = dtLinks;
                dropWebLink.DataBind();
                dropWebLink.Items.Insert(0, new ListItem(MultiLanguage.Initialize.GetString("LinkSite"), "#"));
                dropWebLink.Attributes.Add("onchange", "javascript:go(this);");
            }
		}
        protected void dropCatalogWebLink_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dtlink = LinkDB.GetAllByType(ConvertUtility.ToInt32(dropCatalogWebLink.SelectedValue));
            dropWebLink.DataSource = dtlink;
            dropWebLink.DataBind();
            dropWebLink.Items.Insert(0, new ListItem(MultiLanguage.Initialize.GetString("LinkSite"), "#"));
            dropWebLink.Attributes.Add("onchange", "javascript:go(this);");
        }
	}
}